/** 进销存管理路由 */
import Layout from '@/views/layout/materialLayout'

// 待办事项
const backlogRouteItem = {
  path: 'backlogPsi', // 待办事项
  component: () => import('@/views/psimanagement/psimessage/Message'),
  meta: {
    requiresAuth: false,
    title: '待办事项',
    icon: 'yuzhen-message',
    index: 1,
    type: 'psi',
    num: 0
  }
}
// 产品管理
const materialRouteItem = {
  path: 'material', // 产品管理
  name: 'material',
  component: () => import('@/views/psimanagement/productmanagement/ProductIndex'),
  meta: {
    requiresAuth: true,
    title: '产品管理',
    icon: 'yuzhen-product',
    index: 1,
    type: 'psi',
    subType: 'product'
  }
}

// 入库管理
const enterwarehouseAuth = {
  requiresAuth: true,
  index: 1,
  type: 'psi'
}

const enterwarehouseRouter = {
  path: 'enterwarehouse',
  meta: {
    icon: 'el-icon-folder-add',
    title: '入库管理',
    ...enterwarehouseAuth
  },
  hidden: false,
  children: [{
    path: 'salesEnter', // 销售退货
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '销售退货',
      subType: 'salesEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'purchaseEnter', // 采购入库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '采购入库',
      subType: 'purchaseEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'retrunEnter', // 借用归还
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '归还入库',
      subType: 'retrunEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'repairEnter', // 维修入库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '维修入库',
      subType: 'repairEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'testEnter', // 内部测试入库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '内部测试入库',
      subType: 'testEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'inventoryProfitEnter', // 盘盈
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '盘盈',
      subType: 'inventoryProfitEnter',
      ...enterwarehouseAuth
    }
  }, {
    path: 'otherEnter', // 其它入库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '其它入库',
      subType: 'otherEnter',
      ...enterwarehouseAuth
    }
  }]
}

// 出库管理
const outboundAuth = {
  requiresAuth: true,
  index: 1,
  type: 'psi'
}

const outboundRouter = {
  path: 'borrowOutbound', // 出库管理
  meta: {
    icon: 'el-icon-folder-remove',
    title: '出库管理',
    ...outboundAuth
  },
  hidden: false,
  children: [{
    path: 'salesLeave', // 销售出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '销售出库',
      subType: 'salesLeave',
      ...outboundAuth
    }
  }, {
    path: 'borrowLeave', // 借用出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '借用出库',
      subType: 'borrowLeave',
      ...outboundAuth
    }
  }, {
    path: 'repairLeave', // 维修出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '维修出库',
      subType: 'repairLeave',
      ...outboundAuth
    }
  }, {
    path: 'testLeave', // 内部测试出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '内部测试出库',
      subType: 'testLeave',
      ...outboundAuth
    }
  }, {
    path: 'inventoryLossLeave', // 盘亏出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '盘亏出库',
      subType: 'inventoryLossLeave',
      ...outboundAuth
    }
  }, {
    path: 'otherLeave', // 其它出库
    component: () => import('@/views/psimanagement/Entermanagement/EnterIndex'),
    meta: {
      title: '其它出库',
      subType: 'otherLeave',
      ...outboundAuth
    }
  }]
}
// 仓库管理
const storehouseAuth = {
  requiresAuth: true,
  index: 1,
  type: 'psi'
}

const storehouseRoute = {
  path: 'storehousePath',
  meta: {
    icon: 'el-icon-box',
    title: '仓库管理',
    ...storehouseAuth
  },
  hidden: false,
  children: [
    {
      path: 'storehouse', // 在库查询
      component: () => import('@/views/psimanagement/storeHouseManagement/StoreHouseIndex'),
      meta: {
        title: '仓库管理',
        subType: 'storehouse',
        ...storehouseAuth
      }
    }, {
      path: 'querystorehouse', // 在库查询
      component: () => import('@/views/psimanagement/storeHouseManagement/SearchHouseIndex'),
      meta: {
        title: '库存查询',
        subType: 'querystorehouse',
        ...storehouseAuth
      }
    }
  ]
}

// 数据报表管理
const datareportAuth = {
  requiresAuth: true,
  index: 1,
  type: 'psi'
}

const datareportRoute = {
  path: 'datareportPath',
  meta: {
    icon: 'el-icon-data-analysis',
    title: '数据报表管理',
    ...datareportAuth
  },
  hidden: false,
  children: [
    {
      path: 'elsReport',
      component: () => import('@/views/psimanagement/datareportmanagement/DataReportIndex'),
      meta: {
        title: '出入库报表',
        subType: 'elsReport',
        ...datareportAuth
      }
    }
  ]
}
export const psiRouter = {
  path: '/psi',
  component: Layout,
  redirect: '/psi/backlogPsi',
  name: 'psi',
  hidden: true,
  meta: {
    requiresAuth: true,
    title: '进销存管理',
    index: 0,
    type: 'psi'
  },
  children: [
    backlogRouteItem,
    materialRouteItem,
    ...enterwarehouseRouter.children,
    ...outboundRouter.children,
    ...storehouseRoute.children,
    ...datareportRoute.children
  ]
}

export const psiRouterMenu = [
  backlogRouteItem,
  materialRouteItem,
  enterwarehouseRouter,
  outboundRouter,
  storehouseRoute,
  datareportRoute
]
